#include<string>
#include <numeric>
#include <iostream>
using namespace std;

class Solution {
public:
	bool detectCapitalUse(string word) {
		if(isupper(word[0]))
		{
			//Only one character
			if (word.size() == 1)
				return true;
			int type =isupper(word[1]);
			for(auto i=1;i<word.size();++i)
			{
				if (type != isupper(word[i]))
					return  false;
			}
		}
		else
		{
			if (word.size() == 1)
				return true;			
			for (auto i = 1; i<word.size(); ++i)
			{
				if (!islower(word[i]))
					return  false;
			}			
		}
		return true;
	}
};

int main()
{
	Solution sol;
	cout << sol.detectCapitalUse("HALLP") << endl;
	cout << sol.detectCapitalUse("hG") << endl;
}